package com.jilefojing.controller.convent;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.jilefojing.beans.data.manager.response.BannerData;
import com.jilefojing.beans.data.manager.response.DCategoryData;
import com.jilefojing.beans.data.manager.response.DCategoryData.Attribute;
import com.jilefojing.beans.data.manager.response.EAudioData;
import com.jilefojing.beans.data.manager.response.EVideoData;
import com.jilefojing.beans.data.manager.response.RCategorySourceData;
import com.jilefojing.beans.data.manager.response.RTagSourceData;
import com.jilefojing.beans.data.manager.response.RecommendData;
import com.jilefojing.beans.data.manager.response.TagData;
import com.jilefojing.beans.data.manager.response.UserData;
import com.jilefojing.beans.data.response.base.BaseData;
import com.jilefojing.beans.enums.ItemTypeEnumForSource;
import com.jilefojing.beans.enums.ProgressStatusForSource;
import com.jilefojing.beans.enums.StatusEnumForPublish;
import com.jilefojing.beans.pojos.enhanced.EnhancedBanner;
import com.jilefojing.beans.pojos.enhanced.EnhancedDCategory;
import com.jilefojing.beans.pojos.enhanced.EnhancedEAudio;
import com.jilefojing.beans.pojos.enhanced.EnhancedEVideo;
import com.jilefojing.beans.pojos.enhanced.EnhancedRCategorySource;
import com.jilefojing.beans.pojos.enhanced.EnhancedRTagSource;
import com.jilefojing.beans.pojos.enhanced.EnhancedRecommend;
import com.jilefojing.beans.pojos.enhanced.EnhancedTag;
import com.jilefojing.beans.pojos.enhanced.EnhancedUser;
import com.jilefojing.beans.pojos.enhanced.base.BaseEnhanced;
import com.jilefojing.util.Detect;

public class CommonConvent {
	private static final CommonConvent COMMON_CONVENT = new CommonConvent();

	private CommonConvent() {
	}

	public static List<EVideoData> convent2EVideoDatas(List<EnhancedEVideo> enhancedEVideos) {
		List<EVideoData> videoDatas = new ArrayList<EVideoData>();
		for (EnhancedEVideo _EnhancedEVideo : enhancedEVideos) {
			videoDatas.add(convent2EVideoData(_EnhancedEVideo));
		}
		return videoDatas;
	}

	public static EVideoData convent2EVideoData(EnhancedEVideo enhancedEVideo) {
		EVideoData videoData = new EVideoData();
		BeanUtils.copyProperties(enhancedEVideo, videoData);

		DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");

		if (enhancedEVideo.getCreateTime() != null) {
			videoData.setCreateTime(df.format(enhancedEVideo.getCreateTime()));
		}

		if (enhancedEVideo.getUpdateTime() != null) {
			videoData.setUpdateTime(df.format(enhancedEVideo.getUpdateTime()));
		}

		if (enhancedEVideo.getEnhancedCreateUser() != null) {
			videoData.setCreateUser(convent2UserData(enhancedEVideo.getEnhancedCreateUser()));
		}

		videoData.setEntity(enhancedEVideo.isEntity() ? "是" : "否");

		if (Detect.notEmpty(enhancedEVideo.getEnhancedChildren())) {
			videoData.setChildren(convent2EVideoDatas(enhancedEVideo.getEnhancedChildren()));
			videoData.setState("closed");
		}

		if (enhancedEVideo.getEnhancedParent() != null) {
			videoData.set_parentId(enhancedEVideo.getEnhancedParent().getId());
		}

		if (enhancedEVideo.getEnhancedParent() != null) {
			videoData.setParent(convent2EVideoData(enhancedEVideo.getEnhancedParent()));
		}
		if (enhancedEVideo.getStatus() != null) {
			videoData.setStatusCode(enhancedEVideo.getStatus().getCode());
			videoData.setStatusMsg(enhancedEVideo.getStatus().getMsg());
		}
		if (enhancedEVideo.getProgressStatus() != null) {
			videoData.setProgressStatusCode(enhancedEVideo.getProgressStatus().getCode());
			videoData.setProgressStatusMsg(enhancedEVideo.getProgressStatus().getMsg());
		}

		return videoData;
	}

	public static UserData convent2UserData(EnhancedUser enhancedUser) {
		UserData userData = new UserData();

		BeanUtils.copyProperties(enhancedUser, userData);

		if (enhancedUser.getStatus() != null) {
			com.jilefojing.beans.data.manager.response.UserData.Status status = new com.jilefojing.beans.data.manager.response.UserData.Status(enhancedUser.getStatus().getCode(), enhancedUser
					.getStatus().getMsg());
			userData.setStatus(status);
		}
		return userData;
	}

	public static DCategoryData convent2DCategoryData(EnhancedDCategory enhancedDCategory) {
		DCategoryData dCategoryData = new DCategoryData();
		BeanUtils.copyProperties(enhancedDCategory, dCategoryData);
		dCategoryData.setText(enhancedDCategory.getName());

		if (Detect.notEmpty(enhancedDCategory.getEnhancedChildDCategories())) {
			dCategoryData.setChildren(convent2DCategoryDatas(enhancedDCategory.getEnhancedChildDCategories()));
			dCategoryData.setState("closed");
		}

		Attribute attribute = new Attribute();
		attribute.setCkey(enhancedDCategory.getCkey());
		dCategoryData.setAttribute(attribute);

		DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");

		if (enhancedDCategory.getCreateTime() != null) {
			dCategoryData.setCreateTime(df.format(enhancedDCategory.getCreateTime()));
		}

		if (enhancedDCategory.getUpdateTime() != null) {
			dCategoryData.setUpdateTime(df.format(enhancedDCategory.getUpdateTime()));
		}

		dCategoryData.setEntity(enhancedDCategory.isEntity() ? "是" : "否");

		if (enhancedDCategory.getEnhancedParentDCategory() != null && enhancedDCategory.getEnhancedParentDCategory().getId() > 0) {
			dCategoryData.setParent(convent2DCategoryData(enhancedDCategory.getEnhancedParentDCategory()));
			dCategoryData.set_parentId(enhancedDCategory.getEnhancedParentDCategory().getId());
		}
		if (enhancedDCategory.getEnhancedCreateUser() != null) {
			dCategoryData.setCreateUser(convent2UserData(enhancedDCategory.getEnhancedCreateUser()));
		}
		if (enhancedDCategory.getItemType() != null) {
			dCategoryData.setItemTypeCode(enhancedDCategory.getItemType().getCode());
			dCategoryData.setItemTypeMsg(enhancedDCategory.getItemType().getMsg());
		}

		return dCategoryData;
	}

	public static List<DCategoryData> convent2DCategoryDatas(List<EnhancedDCategory> enhancedDCategories) {
		List<DCategoryData> dCategoryDatas = new ArrayList<DCategoryData>();
		for (EnhancedDCategory _EnhancedDCategory : enhancedDCategories) {
			dCategoryDatas.add(convent2DCategoryData(_EnhancedDCategory));
		}
		return dCategoryDatas;
	}

	public static List<TagData> convent2TagDatas(List<EnhancedTag> enhancedTags) {
		List<TagData> tagDatas = new ArrayList<TagData>();
		for (EnhancedTag _EnhancedTag : enhancedTags) {
			tagDatas.add(convent2TagData(_EnhancedTag));
		}
		return tagDatas;
	}

	public static TagData convent2TagData(EnhancedTag enhancedTag) {
		DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");

		TagData tagData = new TagData();
		BeanUtils.copyProperties(enhancedTag, tagData);
		tagData.setText(enhancedTag.getName());
		if (enhancedTag.getEnhancedCreateUser() != null) {
			tagData.setCreateUser(convent2UserData(enhancedTag.getEnhancedCreateUser()));
		}
		if (enhancedTag.getCreateTime() != null) {
			tagData.setCreateTime(df.format(enhancedTag.getCreateTime()));
		}

		return tagData;
	}

	public static List<RecommendData> convent2RecommendDatas(List<EnhancedRecommend> enhancedRecommends) {
		List<RecommendData> recommendDatas = new ArrayList<RecommendData>();
		for (EnhancedRecommend _EnhancedRecommend : enhancedRecommends) {
			recommendDatas.add(convent2RecommendData(_EnhancedRecommend));
		}
		return recommendDatas;
	}

	public static RecommendData convent2RecommendData(EnhancedRecommend enhancedRecommend) {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		RecommendData recommendData = new RecommendData();
		BeanUtils.copyProperties(enhancedRecommend, recommendData);
		if (enhancedRecommend.getUpdateTime() != null) {
			recommendData.setUpdateTime(df.format(enhancedRecommend.getUpdateTime()));
		}
		if (enhancedRecommend.getCreateTime() != null) {
			recommendData.setCreateTime(df.format(enhancedRecommend.getCreateTime()));
		}

		if (enhancedRecommend.getStartTime() != null) {
			recommendData.setStartTime(df.format(enhancedRecommend.getStartTime()));
		}
		if (enhancedRecommend.getEndTime() != null) {
			recommendData.setEndTime(df.format(enhancedRecommend.getEndTime()));
		}

		if (enhancedRecommend.getEnhancedUser() != null) {
			recommendData.setCreateUser(convent2UserData(enhancedRecommend.getEnhancedUser()));
		}
		if (!Detect.notEmpty(recommendData.getCoverUrl()) && enhancedRecommend.getEnhancedItem() != null) {
			recommendData.setCoverUrl(enhancedRecommend.getEnhancedItem().getString("getCoverUrl"));
		}

		if (!Detect.notEmpty(recommendData.getInfo()) && enhancedRecommend.getEnhancedItem() != null) {
			recommendData.setInfo(enhancedRecommend.getEnhancedItem().getString("getInfo"));
		}
		if (enhancedRecommend.getEnhancedItem() != null) {
			boolean entity = enhancedRecommend.getEnhancedItem().getBoolean("isEntity");
			ItemTypeEnumForSource itemType = ItemTypeEnumForSource.getItemTypeEnumByEnhancedItemClass(enhancedRecommend.getEnhancedItem().getClass());
			StatusEnumForPublish status = (StatusEnumForPublish) enhancedRecommend.getEnhancedItem().get("getStatus");
			ProgressStatusForSource progressStatus = (ProgressStatusForSource) enhancedRecommend.getEnhancedItem().get("getProgressStatus");

			recommendData.setEntity(entity ? "是" : "否");
			BaseEnhanced enhancedParent = (BaseEnhanced) enhancedRecommend.getEnhancedItem().get("getEnhancedParent" + itemType.getItemClass().getSimpleName());
			if (enhancedParent != null) {
				try {
					recommendData.setItemParent(org.apache.commons.beanutils.BeanUtils.describe(enhancedParent));
				} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if (entity) {
				recommendData.setPlaytime(enhancedRecommend.getEnhancedItem().getLong("getPlaytime"));
			} else {
				recommendData.setPlaytime(enhancedRecommend.getEnhancedItem().getLong("getCountCognatePlaytime"));
			}
			recommendData.setTitle(enhancedRecommend.getEnhancedItem().getString("getTitle"));
			recommendData.setCountCognate(enhancedRecommend.getEnhancedItem().getInt("getCountCognate"));
			recommendData.setStatusCode(status.getCode());
			recommendData.setStatusMsg(status.getMsg());
			recommendData.setProgressStatusCode(progressStatus.getCode());
			recommendData.setProgressStatusMsg(progressStatus.getMsg());
			recommendData.setItemId(enhancedRecommend.getEnhancedItem().getDynamicId());
		}

		if (enhancedRecommend.getPlatform() != null) {
			recommendData.setPlatformCode(enhancedRecommend.getPlatform().getCode());
			recommendData.setPlatformMsg(enhancedRecommend.getPlatform().getMsg());
		}

		return recommendData;
	}

	public static Object get(String method, Object value) {
		try {
			for (Method _Method : CommonConvent.class.getDeclaredMethods()) {
				if (_Method.getName().equals(method)) {
					return _Method.invoke(COMMON_CONVENT, value);
				}
			}
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}

	public static List<RCategorySourceData> convent2RCategorySourceDatas(List<EnhancedRCategorySource> enhancedRCategorySources) {
		List<RCategorySourceData> rCategorySourceDatas = new ArrayList<RCategorySourceData>();
		for (EnhancedRCategorySource _EnhancedRCategorySource : enhancedRCategorySources) {
			rCategorySourceDatas.add(convent2RCategorySourceData(_EnhancedRCategorySource));
		}
		return rCategorySourceDatas;
	}

	public static RCategorySourceData convent2RCategorySourceData(EnhancedRCategorySource enhancedRCategorySource) {
		DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");

		RCategorySourceData rCategorySourceData = new RCategorySourceData();
		BeanUtils.copyProperties(enhancedRCategorySource, rCategorySourceData);
		if (enhancedRCategorySource.getUpdateTime() != null) {
			rCategorySourceData.setUpdateTime(df.format(enhancedRCategorySource.getUpdateTime()));
		}

		if (enhancedRCategorySource.getCreateTime() != null) {
			rCategorySourceData.setCreateTime(df.format(enhancedRCategorySource.getCreateTime()));
		}

		if (enhancedRCategorySource.getEnhancedItem() != null) {
			ItemTypeEnumForSource itemType = ItemTypeEnumForSource.getItemTypeEnumByEnhancedItemClass(enhancedRCategorySource.getEnhancedItem().getClass());
			rCategorySourceData.setItem((BaseData) CommonConvent.get("convent2" + itemType.getItemClass().getSimpleName() + "Data", enhancedRCategorySource.getEnhancedItem()));

		}
		if (enhancedRCategorySource.getEnhancedUser() != null) {
			rCategorySourceData.setCreateUser(convent2UserData(enhancedRCategorySource.getEnhancedUser()));
		}
		if (enhancedRCategorySource.getStatus() != null) {
			rCategorySourceData.setStatusCode(enhancedRCategorySource.getStatus().getCode());
			rCategorySourceData.setStatusMsg(enhancedRCategorySource.getStatus().getMsg());
		}
		
		if (enhancedRCategorySource.getEnhancedC1Category() != null) {rCategorySourceData.setC1Category(enhancedRCategorySource.getEnhancedC1Category().getName());}
		if (enhancedRCategorySource.getEnhancedC2Category() != null) {rCategorySourceData.setC2Category(enhancedRCategorySource.getEnhancedC2Category().getName());}
		if (enhancedRCategorySource.getEnhancedC3Category() != null) {rCategorySourceData.setC3Category(enhancedRCategorySource.getEnhancedC3Category().getName());}
		if (enhancedRCategorySource.getEnhancedC4Category() != null) {rCategorySourceData.setC4Category(enhancedRCategorySource.getEnhancedC4Category().getName());}
		if (enhancedRCategorySource.getEnhancedC5Category() != null) {rCategorySourceData.setC5Category(enhancedRCategorySource.getEnhancedC5Category().getName());}
		if (enhancedRCategorySource.getEnhancedC6Category() != null) {rCategorySourceData.setC6Category(enhancedRCategorySource.getEnhancedC6Category().getName());}
		if (enhancedRCategorySource.getEnhancedC7Category() != null) {rCategorySourceData.setC7Category(enhancedRCategorySource.getEnhancedC7Category().getName());}
		if (enhancedRCategorySource.getEnhancedC8Category() != null) {rCategorySourceData.setC8Category(enhancedRCategorySource.getEnhancedC8Category().getName());}
		if (enhancedRCategorySource.getEnhancedC9Category() != null) {rCategorySourceData.setC9Category(enhancedRCategorySource.getEnhancedC9Category().getName());}
		if (enhancedRCategorySource.getEnhancedC10Category() != null) {rCategorySourceData.setC10Category(enhancedRCategorySource.getEnhancedC10Category().getName());}
		if (enhancedRCategorySource.getEnhancedC11Category() != null) {rCategorySourceData.setC11Category(enhancedRCategorySource.getEnhancedC11Category().getName());}
		if (enhancedRCategorySource.getEnhancedC12Category() != null) {rCategorySourceData.setC12Category(enhancedRCategorySource.getEnhancedC12Category().getName());}
		if (enhancedRCategorySource.getEnhancedC13Category() != null) {rCategorySourceData.setC13Category(enhancedRCategorySource.getEnhancedC13Category().getName());}
		if (enhancedRCategorySource.getEnhancedC14Category() != null) {rCategorySourceData.setC14Category(enhancedRCategorySource.getEnhancedC14Category().getName());}
		if (enhancedRCategorySource.getEnhancedC15Category() != null) {rCategorySourceData.setC15Category(enhancedRCategorySource.getEnhancedC15Category().getName());}
		if (enhancedRCategorySource.getEnhancedC16Category() != null) {rCategorySourceData.setC16Category(enhancedRCategorySource.getEnhancedC16Category().getName());}
		if (enhancedRCategorySource.getEnhancedC17Category() != null) {rCategorySourceData.setC17Category(enhancedRCategorySource.getEnhancedC17Category().getName());}
		if (enhancedRCategorySource.getEnhancedC18Category() != null) {rCategorySourceData.setC18Category(enhancedRCategorySource.getEnhancedC18Category().getName());}
		if (enhancedRCategorySource.getEnhancedC19Category() != null) {rCategorySourceData.setC19Category(enhancedRCategorySource.getEnhancedC19Category().getName());}
		if (enhancedRCategorySource.getEnhancedC20Category() != null) {rCategorySourceData.setC20Category(enhancedRCategorySource.getEnhancedC20Category().getName());}
		if (enhancedRCategorySource.getEnhancedC21Category() != null) {rCategorySourceData.setC21Category(enhancedRCategorySource.getEnhancedC21Category().getName());}
		if (enhancedRCategorySource.getEnhancedC22Category() != null) {rCategorySourceData.setC22Category(enhancedRCategorySource.getEnhancedC22Category().getName());}
		if (enhancedRCategorySource.getEnhancedC23Category() != null) {rCategorySourceData.setC23Category(enhancedRCategorySource.getEnhancedC23Category().getName());}
		if (enhancedRCategorySource.getEnhancedC24Category() != null) {rCategorySourceData.setC24Category(enhancedRCategorySource.getEnhancedC24Category().getName());}
		if (enhancedRCategorySource.getEnhancedC25Category() != null) {rCategorySourceData.setC25Category(enhancedRCategorySource.getEnhancedC25Category().getName());}
		if (enhancedRCategorySource.getEnhancedC26Category() != null) {rCategorySourceData.setC26Category(enhancedRCategorySource.getEnhancedC26Category().getName());}
		if (enhancedRCategorySource.getEnhancedC27Category() != null) {rCategorySourceData.setC27Category(enhancedRCategorySource.getEnhancedC27Category().getName());}
		if (enhancedRCategorySource.getEnhancedC28Category() != null) {rCategorySourceData.setC28Category(enhancedRCategorySource.getEnhancedC28Category().getName());}
		if (enhancedRCategorySource.getEnhancedC29Category() != null) {rCategorySourceData.setC29Category(enhancedRCategorySource.getEnhancedC29Category().getName());}
		if (enhancedRCategorySource.getEnhancedC30Category() != null) {rCategorySourceData.setC30Category(enhancedRCategorySource.getEnhancedC30Category().getName());}
		if (enhancedRCategorySource.getEnhancedC31Category() != null) {rCategorySourceData.setC31Category(enhancedRCategorySource.getEnhancedC31Category().getName());}
		if (enhancedRCategorySource.getEnhancedC32Category() != null) {rCategorySourceData.setC32Category(enhancedRCategorySource.getEnhancedC32Category().getName());}
		if (enhancedRCategorySource.getEnhancedC33Category() != null) {rCategorySourceData.setC33Category(enhancedRCategorySource.getEnhancedC33Category().getName());}
		// TODO 可以继续增加 资源类别

		if (enhancedRCategorySource.getItemType() != null) {
			rCategorySourceData.setItemTypeCode(enhancedRCategorySource.getItemType().getCode());
			rCategorySourceData.setItemTypeMsg(enhancedRCategorySource.getItemType().getMsg());
		}
		if (enhancedRCategorySource.getProgressStatus() != null) {
			rCategorySourceData.setProgressStatusCode(enhancedRCategorySource.getProgressStatus().getCode());
			rCategorySourceData.setProgressStatusMsg(enhancedRCategorySource.getProgressStatus().getMsg());
		}

		return rCategorySourceData;
	}

	public static List<RTagSourceData> convent2RTagSourceDatas(List<EnhancedRTagSource> enhancedRTagSources) {
		List<RTagSourceData> rTagSourceDatas = new ArrayList<RTagSourceData>();

		for (EnhancedRTagSource _EnhancedRTagSource : enhancedRTagSources) {
			rTagSourceDatas.add(convent2RTagSourceData(_EnhancedRTagSource));
		}
		return rTagSourceDatas;
	}

	public static RTagSourceData convent2RTagSourceData(EnhancedRTagSource enhancedRTagSource) {
		DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");

		RTagSourceData rTagSourceData = new RTagSourceData();
		BeanUtils.copyProperties(enhancedRTagSource, rTagSourceData);

		if (enhancedRTagSource.getCreateTime() != null) {
			rTagSourceData.setCreateTime(df.format(enhancedRTagSource.getCreateTime()));
		}

		if (enhancedRTagSource.getUpdateTime() != null) {
			rTagSourceData.setUpdateTime(df.format(enhancedRTagSource.getUpdateTime()));
		}

		if (enhancedRTagSource.getEnhancedItem() != null) {
			ItemTypeEnumForSource itemType = ItemTypeEnumForSource.getItemTypeEnumByEnhancedItemClass(enhancedRTagSource.getEnhancedItem().getClass());
			rTagSourceData.setItem((BaseData) CommonConvent.get("convent2" + itemType.getItemClass().getSimpleName() + "Data", enhancedRTagSource.getEnhancedItem()));

		}
		if (enhancedRTagSource.getEnhancedUser() != null) {
			rTagSourceData.setCreateUser(convent2UserData(enhancedRTagSource.getEnhancedUser()));
		}
		if (enhancedRTagSource.getStatus() != null) {
			rTagSourceData.setStatusCode(enhancedRTagSource.getStatus().getCode());
			rTagSourceData.setStatusMsg(enhancedRTagSource.getStatus().getMsg());
		}
		if (enhancedRTagSource.getEnhancedTag() != null) {
			rTagSourceData.setTag(enhancedRTagSource.getEnhancedTag().getName());
		}

		ItemTypeEnumForSource itemType = ItemTypeEnumForSource.getItemTypeEnumByEnhancedItemClass(enhancedRTagSource.getEnhancedItem().getClass());
		rTagSourceData.setItemTypeCode(itemType.getCode());
		rTagSourceData.setItemTypeMsg(itemType.getMsg());

		if (enhancedRTagSource.getProgressStatus() != null) {
			rTagSourceData.setProgressStatusCode(enhancedRTagSource.getProgressStatus().getCode());
			rTagSourceData.setProgressStatusMsg(enhancedRTagSource.getProgressStatus().getMsg());
		}

		return rTagSourceData;
	}

	public static List<EAudioData> convent2EAudioDatas(List<EnhancedEAudio> enhancedEAudios) {
		List<EAudioData> audioDatas = new ArrayList<EAudioData>();
		for (EnhancedEAudio _EnhancedEAudio : enhancedEAudios) {
			audioDatas.add(convent2EAudioData(_EnhancedEAudio));
		}
		return audioDatas;
	}

	public static EAudioData convent2EAudioData(EnhancedEAudio enhancedEAudio) {
		EAudioData audioData = new EAudioData();
		BeanUtils.copyProperties(enhancedEAudio, audioData);

		DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");

		if (enhancedEAudio.getCreateTime() != null) {
			audioData.setCreateTime(df.format(enhancedEAudio.getCreateTime()));
		}

		if (enhancedEAudio.getUpdateTime() != null) {
			audioData.setUpdateTime(df.format(enhancedEAudio.getUpdateTime()));
		}

		if (enhancedEAudio.getEnhancedCreateUser() != null) {
			audioData.setCreateUser(convent2UserData(enhancedEAudio.getEnhancedCreateUser()));
		}

		audioData.setEntity(enhancedEAudio.isEntity() ? "是" : "否");

		if (Detect.notEmpty(enhancedEAudio.getEnhancedChildren())) {
			audioData.setChildren(convent2EAudioDatas(enhancedEAudio.getEnhancedChildren()));
			audioData.setState("closed");
		}

		if (enhancedEAudio.getEnhancedParent() != null) {
			audioData.set_parentId(enhancedEAudio.getEnhancedParent().getId());
		}

		if (enhancedEAudio.getEnhancedParent() != null) {
			audioData.setParent(convent2EAudioData(enhancedEAudio.getEnhancedParent()));
		}
		if (enhancedEAudio.getStatus() != null) {
			audioData.setStatusCode(enhancedEAudio.getStatus().getCode());
			audioData.setStatusMsg(enhancedEAudio.getStatus().getMsg());
		}

		if (enhancedEAudio.getProgressStatus() != null) {
			audioData.setProgressStatusCode(enhancedEAudio.getProgressStatus().getCode());
			audioData.setProgressStatusMsg(enhancedEAudio.getProgressStatus().getMsg());
		}

		return audioData;
	}

	public static List<BannerData> convent2BannerDatas(List<EnhancedBanner> enhancedBanners) {
		List<BannerData> bannerDatas = new ArrayList<BannerData>();
		for (EnhancedBanner _EnhancedBanner : enhancedBanners) {
			bannerDatas.add(convent2BannerData(_EnhancedBanner));
		}
		return bannerDatas;
	}

	public static BannerData convent2BannerData(EnhancedBanner enhancedBanner) {
		BannerData bannerData = new BannerData();
		BeanUtils.copyProperties(enhancedBanner, bannerData);

		if (enhancedBanner.getStatus() != null) {
			bannerData.setStatusCode(enhancedBanner.getStatus().getCode());
			bannerData.setStatusMsg(enhancedBanner.getStatus().getMsg());
		}

		if (enhancedBanner.getPlatform() != null) {
			bannerData.setPlatformCode(enhancedBanner.getPlatform().getCode());
			bannerData.setPlatformMsg(enhancedBanner.getPlatform().getMsg());
		}

		if (enhancedBanner.getEnhancedCreateUser() != null) {
			bannerData.setCreateUser(convent2UserData(enhancedBanner.getEnhancedCreateUser()));
		}

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		if (enhancedBanner.getUpdateTime() != null) {
			bannerData.setUpdateTime(df.format(enhancedBanner.getUpdateTime()));
		}
		if (enhancedBanner.getCreateTime() != null) {
			bannerData.setCreateTime(df.format(enhancedBanner.getCreateTime()));
		}

		if (enhancedBanner.getStartTime() != null) {
			bannerData.setStartTime(df.format(enhancedBanner.getStartTime()));
		}
		if (enhancedBanner.getEndTime() != null) {
			bannerData.setEndTime(df.format(enhancedBanner.getEndTime()));
		}

		return bannerData;
	}
}
